<template>
    <div>
        <heard :title="title"></heard>
        <van-tabs v-model:active="active">
            <van-tab title="商品">
                <swipe :images="images" imagewidth="100%" imageheight="200px"></swipe>
                <div style="font-size: 20px;">{{ detail.goods_name }}</div>
                <div style="color: red;font-size: 20px;">￥{{ detail.goods_price }}</div>
            </van-tab>
            <van-tab title="服务">
                <div v-html="detail.goods_introduce"></div>
            </van-tab>
            <van-tab title="套餐">内容 3</van-tab>
            <van-tab title="评价">内容 4</van-tab>
        </van-tabs>
        <van-action-bar>
            <van-action-bar-icon icon="chat-o" text="客服" dot />
            <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
            <van-action-bar-icon icon="shop-o" text="店铺" badge="12" />
            <van-action-bar-button type="warning" text="加入购物车" @click="add" />
            <van-action-bar-button type="danger" text="立即购买" />
        </van-action-bar>

    </div>
</template>

<script setup>
import heard from '@/components/heard.vue';
import swipe from '@/components/swipe.vue';
const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',
];
const title = '商品详情'
import { ref } from 'vue';
import { detailApi } from '@/api/api';
let detail = ref([])
import { useRoute } from 'vue-router';
const route = useRoute()
detailApi(route.params.goods_id).then(res => {
    console.log('详情', res)
    detail.value = res.data.message
})

import { useRouter } from 'vue-router';
const router=useRouter()
import { useCounterStore } from '@/stores/cart'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()
import _ from 'lodash'
const add=_.debounce(()=>{
    store.pinina(detail.value,route.params.goods_id)
    router.push('/home/cart')
})


</script>

<style lang="scss" scoped></style>